<template>
  <div>
    <van-nav-bar title="注册账号"></van-nav-bar>
    <user-form @onSubmit="onSubmit">
      <template #btn>
        <van-button block type="info">注册</van-button>
      </template>
      <template #link>
        <router-link to="/login">登录账号</router-link>
      </template>
    </user-form>
  </div>
</template>

<script>
import UserForm from "@/components/UserForm.vue";
import { registerAPI } from "../api/user";

export default {
  components: { UserForm },
  methods: {
    async onSubmit(values) {
      await registerAPI(values);
      this.$toast("注册成功");
      this.$router.push("/login");
    },
  },
};
</script>

<style></style>
